#include <iostream>
#include <cstdio>
#include <vector>
#include <climits>
#include <algorithm>
using namespace std;

int main() {
    int n, m;
    cin >> n;
    vector<int> v(n);
    for (int i = 0; i < n; ++i)
    {
        cin >> v[i];
    }

    int maxv = v[0];
    int sum = v[0];
    for (int i = 1; i < n; ++i)
    {
        maxv = max(maxv, max(sum + v[i], sum));
    }
    cout << maxv << endl;

    return 0;
}